package com.luis.demo.repository.impl;

import com.luis.demo.entity.Five;
import com.luis.demo.repository.FiveRepository;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class FiveRepositoryImpl implements FiveRepository {

    private static Map<Long,Five> fivemap;

    static {
        fivemap = new HashMap<>();
        fivemap.put(1L,new Five(1L,"王阳明",334));
        fivemap.put(2L,new Five(2L,"李逵",43));
        fivemap.put(3L,new Five(3L,"李子玉",32));
        fivemap.put(4L,new Five(4L,"陶渊明",39));
    }

    @Override
    public Collection<Five> findAll() {
        return fivemap.values();
    }

    @Override
    public Five findById(long id) {
        return fivemap.get(id);
    }

    @Override
    public void saveOrUpdate(Five five) {
        fivemap.put(five.getId(),five);
    }

    @Override
    public void deleteById(long id) {
        fivemap.remove(id);
    }
}
